{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 9. Mixture Models and EM"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from sklearn.datasets import fetch_openml\n",
    "%matplotlib inline\n",
    "\n",
    "from prml.clustering import KMeans\n",
    "from prml.rv import (\n",
    "    MultivariateGaussianMixture,\n",
    "    BernoulliMixture\n",
    ")\n",
    "\n",
    "np.random.seed(2222)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 9.1 K-means Clustering"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# training data\n",
    "x1 = np.random.normal(size=(100, 2))\n",
    "x1 += np.array([-5, -5])\n",
    "x2 = np.random.normal(size=(100, 2))\n",
    "x2 += np.array([5, -5])\n",
    "x3 = np.random.normal(size=(100, 2))\n",
    "x3 += np.array([0, 5])\n",
    "x_train = np.vstack((x1, x2, x3))\n",
    "\n",
    "x0, x1 = np.meshgrid(np.linspace(-10, 10, 100), np.linspace(-10, 10, 100))\n",
    "x = np.array([x0, x1]).reshape(2, -1).T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARMAAAD8CAYAAABUzEBbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8GearUAAAgAElEQVR4nO2dd5xU1fn/38/02cIuSy+CdOwgiL0rGrGXiCkajSVRk5hYYpJfLNhijSZqolET9WuJsRcEURQsoIKAIr2z9LIL26be5/fHnV1mdu9sY2Yb5/167Wtn7j333nOnfOaUz3keUVUMBoNhd3G1d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PAk4k6zWpq6sL2gLmv9kdHvTcRmdXUYxoUE1U9qRl1WQfslfS8b2JbMtuAQhHxJFonTmUMBkM7IVtTw28D40XELyIDgCHYKUBrUDtj+sfA+YlNlwAt1tIxGAyZZXenhs8RkWLgcOA9EZkMoKrfA68AC4BJwDWqGk8cM1FEeidO8XvgdyKyDHsM5elGXvrJ3al3G8bcV/ujo95bk+9L7AaCwWAw7B7GAWswGDKCERODwZAR2o2Y7K51v70gIreJyDoRmZv4O62167Q7iMipifdlmYjc3Nr1yRQiskpEvku8R02eRm1LiMgzIrJZROYnbSsSkSkisjTxv3ND52k3YsLuW/fbE39V1RGJv4mtXZnmkngfHgN+AOwLXJR4vzoKxyfeo/buM/kP9ncnmZuBj1R1CPBR4nm9tBsx2R3rvqHVGAMsU9UVqhoBXsZ+vwxtCFWdDmyvtfks7CUu0MilLu1GTOqhD7A26Xm9tvx2wrUi8m2i+dlg87IN0xHfm2oU+EBEZieWenQ0eqjqhsTjjUCPhg7I1tqcZtFWrPvZpr77BP4B3IH9Yb0DeBC4rOVqZ2gkR6nqOhHpDkwRkUWJX/gOh6qqiDToIWlTYpJF636borH3KSL/At7NcnWySbt7bxqLqq5L/N8sIm9gd+k6kphsEpFeqrpBRHoBmxs6oCN0cxq07rcnEm9cNedgDzy3V74GhiSCYPmwB8rfbuU67TYikisi+dWPgbG07/fJibexl7hAI5e6tKmWSX2IyDnA34Fu2Nb9uap6iqp+LyLV1v0YSdb9dsp9IjICu5uzCriqdavTfFQ1JiLXApMBN/BMYqlFe6cH8IYdkgcP8KKqTmrdKjUfEXkJOA7omlgecyvwF+AVEfk5sBr4YYPnMXZ6g8GQCTpCN8dgMLQBjJgYDIaMYMTEYDBkBCMmBoMhIxgxMRgMGcGIicFgyAhGTAwGQ0b4/zpkKfQsBj0ZAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "kmeans = KMeans(n_clusters=3)\n",
    "kmeans.fit(x_train)\n",
    "cluster = kmeans.predict(x_train)\n",
    "plt.scatter(x_train[:, 0], x_train[:, 1], c=cluster)\n",
    "plt.scatter(kmeans.centers[:, 0], kmeans.centers[:, 1], s=200, marker='X', lw=2, c=['purple', 'cyan', 'yellow'], edgecolor=\"white\")\n",
    "plt.contourf(x0, x1, kmeans.predict(x).reshape(100, 100), alpha=0.1)\n",
    "plt.xlim(-10, 10)\n",
    "plt.ylim(-10, 10)\n",
    "plt.gca().set_aspect('equal', adjustable='box')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## 9.2 Mixture of Gaussians"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARMAAAD8CAYAAABUzEBbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8GearUAAAgAElEQVR4nO2deXxU1fn/P09msk0S1rC5gAoCglaEiIgbiCJaFXdBWxQXaq2t9ldtXbpQtVatWr8KrSuKVKmgUlBZRBR3EFAQBBQElFVQEBIgkGQ+vz+emcxM5s5kJrmTzMTnndd5Zeaec88994b74ZzzPOc5QhKGYRj1JauxG2AYRtPAxMQwDFcwMTEMwxVMTAzDcAUTE8MwXMHExDAMV3BFTERknIhsFZFlYcdaichsEVkV+N0yxrlXBMqsEpEr3GiPYRgNj1s9k2cBDKlx7FYAc0geDmBO4HsEItIKwF8AHAegL4C/xBIdwzDSG1fEhOS7ALbXODwUwPjA5/EAznM49QwAs0luJ7kDwGxEi5JhGBmAN4V1tyO5OfB5C4B2DmUOBLA+7PuGwLEoRGQUgFEAUFBQ0K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ADA/8vZoKAwN/o0z3M3kW+u6EcyuAOSQPBzAn8D0uGSMm9XHdNxqNvgBWk1xDcj+A/0L/XkYaQfJdANtrHB4KXeICJLjUJWPEJA4HAlgf9j2uW36GcIOIfBboftbavUxjmuLfJggBvCEiiwJLPZoa7UhuDnzeAqBdbSekam1OnUgX1/1UE+8+AfwbwF3Qf6x3AXgQwFUN1zojQU4kuVFE2gKYLSIrA//DNzlIUkRq9SFJKzFJoet+WpHofYrIkwBeS3FzUknG/W0SheTGwO+tIjIFOqRrSmLyrYh0ILlZRDoA2FrbCU1hmFOr634mEfjDBTkfOvGcqSwAcHggCFYOdKJ8WiO3qd6ISIGIFAU/AxiMzP47OTENusQFSHCpS1r1TOIhIucDeBRAG6jr/mKSZ5D8XESCrvuVCHPdz1DuF5Fe0GHOOgC/aNzm1B2SlSJyA4BZADwAxgWWWmQ67QBM0ZA88AJ4geTMxm1S3RGRiQAGACgOLI/5C4B7AUwSkasBfA3gklrrMXd6wzDcoCkMcwzDSANMTAzDcAUTE8MwXMHExDAMVzAxMQzDFUxMDMNwBRMTwzBc4f8DL+/dtoPVZzEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "gmm = MultivariateGaussianMixture(n_components=3)\n",
    "gmm.fit(x_train)\n",
    "p = gmm.classify_proba(x_train)\n",
    "\n",
    "plt.scatter(x_train[:, 0], x_train[:, 1], c=p)\n",
    "plt.scatter(gmm.mu[:, 0], gmm.mu[:, 1], s=200, marker='X', lw=2, c=['red', 'green', 'blue'], edgecolor=\"white\")\n",
    "plt.xlim(-10, 10)\n",
    "plt.ylim(-10, 10)\n",
    "plt.gca().set_aspect(\"equal\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "### 9.3.3 Mixtures of Bernoulli distributions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "x, y = fetch_openml(\"mnist_784\", return_X_y=True)\n",
    "x_train = []\n",
    "for i in [0, 1, 2, 3, 4]:\n",
    "    x_train.append(x[np.random.choice(np.where(y == str(i))[0], 200)])\n",
    "x_train = np.concatenate(x_train, axis=0)\n",
    "x_train = (x_train > 127).astype(np.float)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABGoAAADOCAYAAABmdeTtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8GearUAAAekUlEQVR4nO3de29U1/0u8E0INxuMMeYO5u4UEgKlVaOoL6Bvt6+gqqKqqhRVbSCQAOUOxhjbGAzmYlLOHz8dHemc+T4cNthZwOfz5zzaw56ZvfZasxj5WfP69esOAAAAgF/fZ7/2CQAAAADwP2zUAAAAADTCRg0AAABAI2zUAAAAADTCRg0AAABAIz5P4Zo1a1RC8Ul7/fr1ml/7HAYxNvnUGZvQJmMT2mRsQpuqsekXNQAAAACNsFEDAAAA0AgbNQAAAACNsFEDAAAA0AgbNQAAAACNsFEDAAAA0IhYzw3A+7NmTd2M+fq1dkoAAMAvagAAAACaYaMGAAAAoBE2agAAAAAaYaMGAAAAoBE2agAAAAAaYaMGAAAAoBHqud9SqtdNVO8CiepuAPh0+E5BJV0ba9euLbPPPqt/g/Hf//73nc7p/5auw19++aXM+l73fc/lQ+YXNQAAAACNsFEDAAAA0AgbNQAAAACNsFEDAAAA0AgbNQAAAACNsFEDAAAA0IiPup471X+tX7++zDZu3Fhmqf4rZZ9/Xr/Vz58/H/h4qjZLWapmW15eLjP1wHyK0njpc0yqPzSO+BSl+bavapz1rR9937WlXdfv3tJ1K3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dxlO4Radz2rcVOtd6pzrzPeawmv6gBAAAAaISNGgAAAIBG2KgBAAAAaISNGgAAAIBG2KgBAAAAaMSa9FeN16xZ0+tPHvf9C/PVcekc019Z37RpU5nt3r27zEZGRsostTcNDQ2V2fDwcJlVf2E+NUbMzc2V2ZMnT8osNXr0bdtJ7U19/tJ217XT7vT69ev3X5fwHvQdm61I94j0l+5Tk1saf+n6Xb9+fZlV12Hf9or0F/KTdP6fKmPzf6S2lz7HrESW5uI0h6dsw4YNZVZJLTCp6WUlxvTHzNhcGSsxVtLaNM3FKRsdHR34eFrXpTVBGmNp3ZoaGFMjUHrOtKZN51kdt9rNMp/S2OzTkpbGUZrj0joyrVv7Nrmlay1d29VaMl3XK9Hgyv+rGpt+UQMAAADQCBs1AAAAAI2wUQMAAADQCBs1AAAAAI2wUQMAAADQCBs1AAAAAI1YkXruVvStFEu1g+k5+9ZbV8e94bMps776PmcrVdor4VOqMvzQ9R2bfa77dMzHPB5aYmxCm4zNLM0fK1GFm55zaGiozNauXdvrOassrYNTLfKLFy/KbHl5+a3Po+vyPJ2qij/0ymFjE9qknhsAAACgcTZqAAAAABphowYAAACgETZqAAAAABphowYAAACgETZqAAAAABrxUddzw7tSZQhtMjahTcZmf33ruT8EH3q19cfA2IQ2qecGAAAAaJyNGgAAAIBG2KgBAAAAaISNGgAAAIBG2KgBAAAAaISNGgAAAIBGfP5rnwAAAHzqVFgD8L/5RQ0AAABAI2zUAAAAADTCRg0AAABAI2zUAAAAADTCRg0AAABAI2zUAAAAADRijSpAAAAAgDb4RQ0AAABAI2zUAAAAADTCRg0AAABAI2zUAAAAADTCRg0AAABAI2zUAAAAADTifwHH19WzmkBLvQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1440x360 with 5 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "bmm = BernoulliMixture(n_components=5)\n",
    "bmm.fit(x_train)\n",
    "\n",
    "plt.figure(figsize=(20, 5))\n",
    "for i, mean in enumerate(bmm.mu):\n",
    "    plt.subplot(1, 5, i + 1)\n",
    "    plt.imshow(mean.reshape(28, 28), cmap=\"gray\")\n",
    "    plt.axis('off')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
